﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>
<!--#include file="abcd.asp"-->
<%
if sid="Null" then
%>
<%=title1%>
	<%=we%>你还没登陆,请先登陆。<%=we0%>
	<%=sou%><a href="/login.asp?sid=<%=sidd%>&amp;url=/riji/fat.asp?listid=<%=listid%>">马上登陆</a><%=we0%>
 
		<%
else

IF  Request.QueryString("Action")="save" Then
	call save
else
	call index
end if

end if
End Function




Function index
%>
<!--#include file="abcd.asp"-->
<%
	randomize
	RndTXT=int((99999999)*rnd+1)
%>
<%=title3%>
<%if v=0 then %>
	标题:<br/><input emptyok="true"  type="text" maxlength="40" name="name<%=RndTXT%>" size="15"/><br/>
	内容:<br/><input emptyok="true"  type="text" name="content<%=RndTXT%>" size="15"/><br/>
	<anchor>发表日记
    	<go href="fat.asp?Action=save&amp;sid=<%=sidd%>" method='post'>
        <postfield name="name" value="$(name<%=RndTXT%>)"/>
        <postfield name="content" value="$(content<%=RndTXT%>)"/>
    	</go>
	</anchor><br/>
<%else%>
<form action="fat.asp?Action=save&amp;sid=<%=sidd%>" method="post">
<%=we%>标题:<%=we0%>
<input emptyok="true"  type="text" maxlength="40" name="name"" format="*N" size="10"/><br/>
<%=we%>内容:<%=we0%><%=sou%><textarea name="content" rows="4"/><%=rep%></textarea><%=we0%>
<input type="submit" value="发表日记"/><br/>
</form>
<%end if%>
<%=hr%>
<%=sou%><a href="index.asp?sid=<%=sidd%>">返回我的日记</a><%=we0%> 
<%
End Function


Function save

dim id,name

		if DATEDIFF("s", session("addtime"), now()) >600 then
		session("addtime")=now
		session("addcount")=0
		end if
		Set Rs = Server.CreateObject("Adodb.Recordset")

	IF Request.form("name")<>"" and Request.form("content")<>""  and session("addBoard")<>Request.form("content") and session("addcount")<5  then
		dim content,member,rs,nid,ip,sql,zz
		ip=Request.ServerVariables("REMOTE_ADDR")

		name=Request.form("name")
		content=Request.form("content")
		name=qingtian.repsql(name)
		content=qingtian.repsql(content)
                faee=qingtian.inlof("faee")
                fae=qingtian.inlof("fae")

		Sql = "select [id],[zf],[money] FROM qingtian_user where [sid]='"&md5(sid) & md5(strReverse(sid))&"'"
		Rs.Open Sql,conn,1,3
		if not (rs.eof and rs.bof) then
			nid=rs("id")
			rs("zf")=rs("zf")+faee
			rs("money")=rs("money")+fae
			rs.update
		else
			nid=0
		end if
		Rs.close


		Sql = "select top 1  [posttime] FROM qingtian_bbs_forum where [content]='"&content&"' and [name]='"&name&"' order by [id] desc"
		Rs.Open Sql,conn,1,1
		if not (rs.eof and rs.bof) then

			if DATEDIFF("s", rs("posttime"), now()) > 60*60 then
			zz=0
			else
			zz=1
			end if
		else
			zz=0
		end if
		Rs.close

		if zz=0 then

                Path="/riji/riji/" & qingtian.nid & "/"

		Sql = "select top 1 id FROM qingtian_riji order by [id] desc"
                Rs.Open Sql,conn,1,1
		if not (rs.eof and rs.bof) then
                tad=rs("id")+1
                end if
                Rs.close
		qingtian.CreateFolder Path
		path=path & tad & ".txt"
		qingtian.CreateFilett content,path
		Sql = "select [nid],[name],[conurl] FROM qingtian_riji"
		Rs.Open Sql,conn,1,3
		rs.addnew
		rs("nid")=qingtian.nid
		rs("name")=name
		rs("conurl")=path
		rs.update
		Rs.close
		Sql = "select top 1 [id] from [qingtian_riji] where nid="&nid&" order by [id] desc"
		Rs.Open Sql,conn,1,1
		if not (rs.eof and rs.bof) then
		id=rs("id")
		end if
		Rs.close
	set rs=nothing
%>
<!--#include file="abcd.asp"-->
<%
		session("addBoard")=content
		if session("addtime")<>"" then
		if DATEDIFF("s", session("addtime"), now()) >20 then
		session("addtime")=now
		session("addcount")=1
		else
		session("addtime")=now
		session("addcount")=session("addcount")+1
		end if
		else
		session("addtime")=now
		session("addcount")=1
		end if
		if session("addcount")>2 then
		%>
<%=title4%>
<%=we%>你好,请注意一下了..你已经一口气发了<%=session("addcount")%>编日记了.<br/><%
		end if
		%>
<%=title6%>
<%=we%>发表日记成功.<br/>你的积分增加<%=zi%><%=faee%><%=zi0%>，你的<%=qingtian.bi%>增加<%=zi%><%=fae%><%=zi0%>，今日系统剩余<%=qingtian.bi%>:<%=zi%><%=qingtian.inlof("mot")%><%=zi0%>。<%=we0%>
		<%
                qingtian.addong("成功发表一篇日记")
		else
		%>
<!--#include file="abcd.asp"-->
<%=title5%><%=we%>请不要发重复的日记!<br/><%
		end if

	else
%>
<!--#include file="abcd.asp"-->
<%=title5%><%=we%>
		<%if Request.form("name")="" then%>
		标题不能为空。<br/>
		<%end if%>
		<%if Request.form("content")="" then%>
		内容不能为空。<br/>
		<%end if%>
		<%if len(Request.form("content"))>0 and session("addBoard")=Request.form("content") then%>
		请不要重复提交。<br/>
		<%end if%>
		<%
		if session("addcount")>4 then
		%>你好,你好你的操作过快..请休息一下在回复,休息时间倒记时:<%=600-DATEDIFF("s", session("addtime"), now())%>秒.<br/><%
		end if
		%>
		<a href="fat.asp?sid=<%=sidd%>">返回修改</a><br/>
<%	end if

%>
<%=hr%>
<%=sou%><a href="index.asp?sid=<%=sidd%>">返回我的日记</a><%=we0%> 
<%
end Function 
%>
